<template>
  <div class="nav-item" @mouseenter="live2dShowNav">
    <div @click="goPath">
        <pop-tip v-if="showPopTip" class="nav-popTip" :style="{left:left,top:top}">
            <div style="font-size:2px">
                {{ackData.otcDescribe}}
            </div>
        </pop-tip>
      <div class="nav-img" :style="{ backgroundColor: ackData.bgColor }">
        <img :src="ackData.otcPath" alt="" width="50px" height="50px" />
      </div>
      <div class="nav-name">
        {{ ackData.otcName }}
      </div>
      <div class="nav-desc" @mousemove="pathDesc">
        {{ ackData.otcDescribe }}
        
      </div>
    </div>
    <div class="nav-path">
      <i
        class="iconfont iconshouye1"
        @click="goNav(ackData.path)"
        v-if="ackData.path"
      ></i>
      <i
        class="iconfont icongithub"
        @click="goNav(ackData.name)"
        v-if="ackData.name"
      ></i>
    </div>
  </div>
</template>

<script>
import popTip from "../../../components/popTipDes.vue";
import Bus from "../../../bus";

export default {
  props: {
    ackData: {
      type: Object,
      default: () => ({}),
    },
  },
  components:{
      popTip
  },
  data() {
      return {
          descTime:null,
          showDesc:false,
          left:"",
          top:"",
          showPopTip:false
      }
  },
  methods: {
      pathDesc(e){
          this.showPopTip = false
          if(this.descTime){
              clearTimeout(this.descTime)
          }
          this.descTime = setTimeout(()=>{
              this.showPopTip = true
              this.left = e.offsetX+'px'
              this.top = (e.offsetY+73)+'px'
          },1300)
      },
    goPath() {
      this.ackData.path
        ? this.goNav(this.ackData.path)
        : this.goNav(this.ackData.name);
    },
    live2dShowNav(){
      Bus.$emit("live2dAboutNavigation", { title: this.ackData.otcDescribe });
    },
    goNav(path) {
      let a = document.createElement("a");
      a.href = path;
      a.target = "_blank";
      a.click();
    },
  },
};
</script>

<style lang="less" scoped>
.nav-item {
  width: 150px;
  // height: 200px;
  padding: 5px;
  margin: 15px;
  transition: all 0.2s;
  border-radius: 6px;
  position: relative;
  &:hover {
  z-index: 200;
    box-shadow: 0 0 7px 1px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
  }
  .nav-popTip{
      position: absolute;
    left: 0;
    z-index: 9;
  }
  .nav-img {
    text-align: center;
  }
  .nav-name {
    font-weight: 200;
    color: #333;
    text-align: center;
  }
  .nav-desc {
    width: 150px;
    height: 51px;
    margin-top: 2px;
    font-size: 12px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    color: rgba(0, 0, 0, 0.4);
    position: relative;
  }
  .nav-path {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    color: rgba(0, 0, 0, 0.4);
    i{
        transition: all 0.3s;
        &:hover{
            color: skyblue;
        }
    }
  }
}
</style>